#!/usr/bin/env python
"""
 Copyright (c) 2017 Intel Corporation

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

from dynamic_reconfigure.parameter_generator_catkin import double_t
from dynamic_reconfigure.parameter_generator_catkin import int_t
from dynamic_reconfigure.parameter_generator_catkin import str_t
from dynamic_reconfigure.parameter_generator_catkin import ParameterGenerator

gen = ParameterGenerator()

comparators = gen.enum(
    [
      gen.const("PlaneCoefficientComparator", int_t, 0, "Plane Coefficient Comparator"),
      gen.const("EuclideanPlaneCoefficientComparator", int_t, 1, "Euclidean Plane Coefficient Comparator"),
      gen.const("RGBPlaneCoefficientComparator", int_t, 2, "RGB Plane Coefficient Comparator"),
      gen.const("EdgeAwarePlaneComparator", int_t, 3, "Edge Aware Plane Comparator"),
    ],
    "Comparator to be used for segmetation")

gen.add(
    "comparator",
    int_t,
    0,
    "Comparator to be used for segmentation",
    0,
    0,
    3,
    edit_method=comparators)

gen.add(
    "min_cluster_size",
    int_t,
    0,
    "The minimum number of points that a cluster needs to contain in order to be considered valid",
    300,
    10,
    10000)

gen.add(
    "min_plane_inliers",
    int_t,
    0,
    "The mininum number of inliers required for a plane",
    1000,
    100,
    10000)

gen.add(
    "normal_max_depth_change",
    double_t,
    0,
    "The depth in meters change threshold for computing object borders",
    0.02,
    0.001,
    0.1)

gen.add(
    "normal_angle_threshold",
    double_t,
    0,
    "The tolerance in degrees for difference in normal direction between neighboring points,"
    " to be considered part of same plane",
    2.0,
    0.01,
    45.0)

gen.add(
    "normal_distance_threshold",
    double_t,
    0,
    "The tolerance in meters for difference in perpendicular distance to the plane between neighboring points,"
    " to be considered part of same plane",
    0.02,
    0.001,
    0.1)

gen.add(
    "normal_smooth_size",
    double_t,
    0,
    "The factor which influences the size of the area used to smooth normals",
    30.0,
    1.0,
    100.0)

gen.add(
    "euclidean_distance_threshold",
    double_t,
    0,
    "Max distance for two objects to be considered as separated",
    0.02,
    0.001,
    0.1)

gen.add(
    "plane_minimum_points",
    int_t,
    0,
    "Minimum points count for a cluster to be consider as a plane",
    2000,
    1000,
    20000)

gen.add(
    "object_minimum_points",
    int_t,
    0,
    "Minimum points count for a cluster to be consider as an object",
    200,
    1,
    5000)

exit(gen.generate("object_analytics_nodelet", "object_analytics", "OrganizedMultiPlaneSegmentation"))
